// 
//	jQuery Validate example script
//
//	Prepared by David Cochran
//	
//	Free for your use -- No warranties, no guarantees!
//

$(document).ready(function(){

	// Validate
	// http://bassistance.de/jquery-plugins/jquery-plugin-validation/
	// http://docs.jquery.com/Plugins/Validation/
	// http://docs.jquery.com/Plugins/Validation/validate#toptions
	
		$('#contact-form').validate({
	    rules: {
	      name: {
	        minlength: 2,
	        required: true
	      },
	      email: {
	        required: true,
	        email: true
	      },
	      subject: {
	      	minlength: 2,
	        required: true
	      },
	      message: {
	        minlength: 2,
	        required: true
	      }
	    },
	    highlight: function(label) {
	    	$(label).closest('.control-group').addClass('error');
	    },
	    success: function(label) {
	    	label
	    		.append('<img src="img/tick.png"/>')
	    		.closest('.control-group').addClass('success');
	    }
	  });
	  
	  $('#loginForm').validate({
	    rules: {
	      userName: {
	        required: true
	      },
	      password: {
	        required: true
	      }
	    },
	    highlight: function(label) {
	    	$(label).closest('.control-group').addClass('error');
	    },
	    success: function(label) {
	    	label
	    		.append('<img style="width: 10px; height: 10px" src="img/tick.png"/>')
	    		.closest('.control-group').addClass('success');
	    }
	  });
	  
	  $('#viewCustomerForm').validate({
		    rules: {
		    	username: {
		        required: true,
		        maxlength: 15
		      }
		     
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#changePasswordForm').validate({
		    rules: {
		    	oldPassword: {
		        required: true,
		        maxlength: 40
		      },
	  			newPassword: {
	  			required: true,
	  			maxlength: 40
	  		  },
	  		  	confirmPassword: {
	  			required: true,
	  			maxlength: 40
	      }
		     
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#createCusAccountForm').validate({
		    rules: {
		    	firstName: {
		        required: true,
		        maxlength: 15
		      },
		      	lastName: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		  	userName: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		  	password: {
	  			required: true,
	  			maxlength: 40
	  		  },
	  		  	confirm: {
		  			required: true,
		  			maxlength: 40
	  		  },
	  		  	address1: {
		  			required: true,
		  			maxlength: 20
	  		  },
	  		  	address2: {
		  			
		  			maxlength: 20
	  		  },
	  		  	city: {
		  			required: true,
		  			maxlength: 20
	  		  },
	  		  	zipCode: {
	  			required: true,
	  			maxlength: 5,
	  			digits: true
	  		  },
	  		  	phoneNo: {
	  			required: true,
	  			maxlength: 15
	  		},
	  			cashAmount: {
	  			required: true,
	  			maxlength: 9,
	  			number: true
	  		}
		     
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#createEmpAccountForm').validate({
		    rules: {
		    	firstName: {
		        required: true,
		        maxlength: 15
		      },
		      	lastName: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		  	userName: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		  	password: {
	  			required: true,
	  			maxlength: 40
	  		  },
	  		  	confirm: {
		  			required: true,
		  			maxlength: 40
	  		  }
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#changeCusPasswordForm').validate({
		    rules: {
	  		  	userName: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		  	newPassword: {
	  			required: true,
	  			maxlength: 40
	  		  },
	  		  	confirmPassword: {
		  			required: true,
		  			maxlength: 40
	  		  }
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#viewCusTransactionHistoryForm').validate({
		    rules: {
		    	username: {
	  			required: true,
	  			maxlength: 15
	  		  }
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#depositCheckForm').validate({
		    rules: {
		    	customerName: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		  	amountString: {
	  			required: true,
	  			maxlength: 9,
	  			number: true
	  		}
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#createFundForm').validate({
		    rules: {
		    	fundname: {
	  			required: true,
	  			maxlength: 15
	  		  },
	  		    ticker: {
	  			required: true,
	  			maxlength: 5
	  		}
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#transitionDayForm').validate({
		    rules: {
		    	dateString: {
	  			required: true,
	  			date: true
	  		  }
		    }
		  });
	  
	  $('#buyFundForm').validate({
		    rules: {
		    	amount: {
	  			required: true,
	  			maxlength: 15,
	  			number: true
	  		  }
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
	  
	  $('#requestCheckForm').validate({
		    rules: {
		    	amount: {
	  			required: true,
	  			maxlength: 15,
	  			number: true
	  		  }
		    },
		    highlight: function(label) {
		    	$(label).closest('.control-group').addClass('error');
		    }
		  });
}); // end document.ready